package trader;
import trader.db.*;
import trader.gui.*;
import javax.swing.*;

public class Broker2TierApp {

    //Starting X and Y positions
    public static final int X = 10;
    public static final int Y = 30;
    
    /** Creates a new instance of Broker2TierApp */
    public static void main(String args[]) {
        String dbHost = "localhost";
        try {
            if (args.length > 0) {
                dbHost = args[0];
            }
            UIManager.setLookAndFeel(
                    UIManager.getSystemLookAndFeelClassName());

            BrokerDAO       dao   = new trader.db.BrokerDAOImpl(dbHost);
            BrokerModel     model = new trader.db.BrokerModelImpl(dao);

            /** ---------------------------------------------------------------
             * GUI I Stuff
             */
            final BrokerGui gui1  = new BrokerGui(model);
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    gui1.setLocation(X, Y);
                    gui1.setVisible(true);
                }
            });

            BrokerViewImpl   view1 = new BrokerViewImpl(model, gui1);
            BrokerController con1  = new BrokerControllerImpl(model, view1);

            /** ---------------------------------------------------------------
             * GUI II Stuff
             */
            final BrokerGui gui2  = new BrokerGui(model);
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    gui2.setLocation(
                            (int)(gui1.getBounds().getWidth() + X), Y);
                    gui2.setVisible(true);
                }
            });
            
            BrokerViewImpl   view2 = new BrokerViewImpl(model, gui2);
            BrokerController con2  = new BrokerControllerImpl(model, view2);

        } catch (Exception e) {
            System.out.println(e.toString());
        }
    }
}
